%Calculate Second Best Outcome for alpha\not =0;
%Analogous to SB.m


iGridB=1000;
aBGrid=linspace(0,aBar,iGridB);

for i=1:iGridB
    
    aB=aBGrid(i);
    
    W=aB*phi/(1+alpha*q);
    FB=1-(gamma-r)*W*Agency-0.5*phi*aB^2;
    FB=FB/(r+Lambda-aB-q-alpha*aB*q);
    vFB(i)=FB;
    
end

[FB,ind]=max(vFB);
aB=aBGrid(ind);
WB=phi*aB/(1+alpha*q);
lambdaB=Lambda-aB-q-alpha*aB*q;

cB=((gamma+lambdaB+delta)*WB+0.5*phi*aB^2)/(1+delta*FB);
VB=(1+alpha*aB)*WB/(gamma+lambdaB+delta);
DB=mu/(r+lambdaB);
tauB=1/lambdaB;
betaB=cB/mu;
